WPS Office.apk(点击下载) / abjx.java


package defpackage;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.dom4j.DocumentFactory;
import org.xml.sax.Attributes;

/* renamed from: abjx  reason: default package */
public abstract class abjx extends abjr implements abir {
    private static final DocumentFactory CSI = DocumentFactory.hfO();

    @Override // defpackage.abjr
    public Iterator<abix> IE() {
        return IF().iterator();
    }

    @Override // defpackage.abir
    public final String Id() {
        return hfK().Id();
    }

    @Override // defpackage.abir, defpackage.abjz, defpackage.abix
    public String Ik() {
        List<abix> IF = IF();
        int size = IF.size();
        if (size <= 0) {
            return "";
        }
        if (size == 1) {
            return c(IF.get(0));
        }
        StringBuffer stringBuffer = new StringBuffer();
        for (int i = 0; i < size; i++) {
            String c = c(IF.get(i));
            if (c.length() > 0) {
                stringBuffer.append(c);
            }
        }
        return stringBuffer.toString();
    }

    @Override // defpackage.abir
    public int Il() {
        return hga().size();
    }

    /* access modifiers changed from: protected */
    @Override // defpackage.abjr
    public final void a(int i, abix abix) {
        if (abix.hfU() != null) {
            throw new abiv((abir) this, abix, "The Node already has an existing parent of \"" + abix.hfU().Id() + "\"");
        }
        IF().add(i, abix);
        g(abix);
    }

    public void a(abij abij) {
        if (abij.hfU() != null) {
            throw new abiv((abir) this, (abix) abij, "The Attribute already has an existing parent \"" + abij.hfU().Id() + "\"");
        } else if (abij.getValue() == null) {
            abij d = d(abij.hfK());
            if (d != null) {
                b(d);
            }
        } else {
            hga().add(abij);
            g(abij);
        }
    }

    @Override // defpackage.abjr
    public final void a(abin abin) {
        e(abin);
    }

    @Override // defpackage.abir
    public final void a(abiw abiw) {
        e(abiw);
    }

    @Override // defpackage.abjr
    public final void a(abja abja) {
        e(abja);
    }

    @Override // defpackage.abir
    public final void a(Attributes attributes, int i, abkw abkw, boolean z, abjm abjm) {
        if (i > 0) {
            hgc();
            List<abij> hgb = hgb();
            hgb.clear();
            for (int i2 = 0; i2 < i; i2++) {
                String qName = attributes.getQName(i2);
                if (!qName.startsWith("xmlns")) {
                    String uri = attributes.getURI(i2);
                    String localName = attributes.getLocalName(i2);
                    String value = attributes.getValue(i2);
                    if (true != abjm.aSF) {
                        if (true == "http://schemas.openxmlformats.org/markup-compatibility/2006".equals(uri) || abjm.CSo.w(uri, null, true) != null) {
                        }
                    }
                    abij a = DocumentFactory.a(abkw.bA(uri, localName, qName), value);
                    hgb.add(a);
                    g(a);
                }
            }
        }
    }

    @Override // defpackage.abir
    public final abir ajk(String str) {
        hgc();
        j(DocumentFactory.ajh(str));
        return this;
    }

    @Override // defpackage.abir
    public final abir ajl(String str) {
        hgc();
        j(DocumentFactory.ajg(str));
        return this;
    }

    @Override // defpackage.abir
    public final abir ajm(String str) {
        hgc();
        j(DocumentFactory.aji(str));
        return this;
    }

    @Override // defpackage.abir
    public abij ajn(String str) {
        List<abij> hga = hga();
        int size = hga.size();
        for (int i = 0; i < size; i++) {
            abij abij = hga.get(i);
            if (str.equals(abij.getName())) {
                return abij;
            }
        }
        return null;
    }

    @Override // defpackage.abir
    public abir ajo(String str) {
        for (abix abix : IF()) {
            abir a = abiy.a(abix);
            if (a != null && str.equals(a.getName())) {
                return a;
            }
        }
        return null;
    }

    @Override // defpackage.abir
    public abij azV(int i) {
        return hga().get(i);
    }

    /* access modifiers changed from: protected */
    @Override // defpackage.abjz
    public final void b(StringBuilder sb) {
        String namespaceURI = hfK().getNamespaceURI();
        super.b(sb);
        sb.append(" [Element: <");
        sb.append(hfK().Id());
        if (namespaceURI != null && namespaceURI.length() > 0) {
            sb.append(" uri: ");
            sb.append(namespaceURI);
        }
        sb.append(" attributes: ");
        sb.append(hga());
        sb.append("/>]");
    }

    public boolean b(abij abij) {
        List<abij> hga = hga();
        boolean remove = hga.remove(abij);
        if (remove) {
            h(abij);
            return remove;
        }
        abij d = d(abij.hfK());
        if (d == null) {
            return remove;
        }
        hga.remove(d);
        return true;
    }

    @Override // defpackage.abir
    public List<abir> cx(String str) {
        abkc hfY = hfY();
        List<abix> IF = IF();
        int size = IF.size();
        for (int i = 0; i < size; i++) {
            abix abix = IF.get(i);
            if (str.equals(abix.getName()) && abix.hfS() == abiz.ELEMENT_NODE) {
                ev.eH();
                hfY.k((abir) abix);
            }
        }
        return hfY;
    }

    public abij d(abjb abjb) {
        for (abij abij : hga()) {
            if (abjb.equals(abij.hfK())) {
                return abij;
            }
        }
        return null;
    }

    @Override // defpackage.abjr
    public final void d(abir abir) {
        e(abir);
    }

    @Override // defpackage.abjr
    public final void d(abix abix) {
        switch (abix.hfS()) {
            case ELEMENT_NODE:
                e((abir) abix);
                return;
            case ATTRIBUTE_NODE:
                a((abij) abix);
                return;
            case TEXT_NODE:
                e((abjc) abix);
                return;
            case CDATA_SECTION_NODE:
                e((abil) abix);
                return;
            case ENTITY_REFERENCE_NODE:
                e((abiu) abix);
                return;
            case PROCESSING_INSTRUCTION_NODE:
                e((abja) abix);
                return;
            case COMMENT_NODE:
                e((abin) abix);
                return;
            case NAMESPACE_NODE:
                e((abiw) abix);
                return;
            default:
                i(abix);
                return;
        }
    }

    /* access modifiers changed from: protected */
    @Override // defpackage.abjr
    public final void e(abix abix) {
        if (abix.hfU() != null) {
            throw new abiv((abir) this, abix, "The Node already has an existing parent of \"" + abix.hfU().Id() + "\"");
        }
        j(abix);
    }

    /* access modifiers changed from: protected */
    @Override // defpackage.abjr
    public boolean f(abix abix) {
        boolean remove = IF().remove(abix);
        if (remove) {
            h(abix);
        }
        return remove;
    }

    public final void g(abir abir) {
        int Il = abir.Il();
        for (int i = 0; i < Il; i++) {
            abij azV = abir.azV(i);
            if (azV.hfT()) {
                abjb hfK = azV.hfK();
                String value = azV.getValue();
                abij d = d(hfK);
                if (value != null) {
                    if (d == null) {
                        hgc();
                        a(DocumentFactory.a(hfK, value));
                    } else if (d.isReadOnly()) {
                        b(d);
                        hgc();
                        a(DocumentFactory.a(hfK, value));
                    } else {
                        d.setValue(value);
                    }
                } else if (d != null) {
                    b(d);
                }
            } else {
                a(azV);
            }
        }
    }

    /* access modifiers changed from: protected */
    @Override // defpackage.abjr
    public final void g(abix abix) {
        ev.assertNotNull("node should not be null", abix);
        abix.b(this);
    }

    @Override // defpackage.abjz, defpackage.abix
    public final String getName() {
        return hfK().name;
    }

    /* access modifiers changed from: protected */
    @Override // defpackage.abjr
    public final void h(abix abix) {
        ev.assertNotNull("node should not be null", abix);
        abix.b(null);
        abix.a(null);
    }

    @Override // defpackage.abir
    public final Iterator<abir> hfQ() {
        return hfZ().iterator();
    }

    @Override // defpackage.abjz, defpackage.abix
    public final abiz hfS() {
        return abiz.ELEMENT_NODE;
    }

    public List<abir> hfZ() {
        ArrayList arrayList = new ArrayList();
        List<abix> IF = IF();
        int size = IF.size();
        for (int i = 0; i < size; i++) {
            abix abix = IF.get(i);
            if (abix.hfS() == abiz.ELEMENT_NODE) {
                ev.eH();
                arrayList.add((abir) abix);
            }
        }
        return arrayList;
    }

    /* access modifiers changed from: protected */
    public abstract List<abij> hga();

    /* access modifiers changed from: protected */
    public abstract List<abij> hgb();

    /* access modifiers changed from: protected */
    @Override // defpackage.abjz
    public DocumentFactory hgc() {
        DocumentFactory documentFactory;
        abjb hfK = hfK();
        return (hfK == null || (documentFactory = hfK.CSi) == null) ? CSI : documentFactory;
    }

    @Override // defpackage.abir
    public final abir iU(String str, String str2) {
        hgc();
        j(DocumentFactory.iS(str, str2));
        return this;
    }

    @Override // defpackage.abir
    public final abir iV(String str, String str2) {
        hgc();
        j(DocumentFactory.iT(str, str2));
        return this;
    }

    /* access modifiers changed from: protected */
    public void j(abix abix) {
        IF().add(abix);
        g(abix);
    }

    @Override // defpackage.abjz, defpackage.abix
    public final void setName(String str) {
        c(hgc().ajj(str));
    }
}